package com.wj.algorithm.lintcode;

import com.wj.algorithm.ArrayUtil;

public class P56 {
    private void create(int[] arr, int v1, int v2) {
        arr[0] = Math.min(v1, v2);
        arr[1] = Math.max(v1, v2);
    }
    public int[] twoSum(int[] numbers, int target) {

        if(numbers == null || numbers.length < 2) {
            return new int[0];
        }
        int len = numbers.length;
        int[] rs = new int[2];
        for(int i = 0; i < len; i ++) {
            for(int j = 0; j < len; j ++) {
                if(i != j && numbers[i] + numbers[j] == target) {
                    create(rs, i + 1, j + 1);
                    return rs;
                }
            }
        }
        return rs;
    }
    
    public static void main(String[] args) {
        System.out.println(ArrayUtil.toString(new P56().twoSum(new int[]{2, 7, 11, 15}, 9)));
        
    }
}
